package com.my.fo.execption;

import com.my.fo.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice(basePackages = "com.my.fo")
public class ExceptionControllerAdvice {

    @ExceptionHandler(value = RuntimeException.class)
    public R<?> handleException(RuntimeException e){
        log.error("{}", e.getMessage(), e);
        return R.error(e.getMessage());
    }

    @ExceptionHandler(value = Exception.class)
    public R<?> handleException(Exception e){
        log.error("{}", e.getMessage(), e);
        return R.error(e.getMessage());
    }

}
